<template>
  <el-tabs v-model="activeName" class="bg-[#232324] w-[300px]">
    <el-tab-pane label="图表" name="charts" class="bg-[#232324] pb-[100px]">
      <el-scrollbar height="100%" class="bg-[#18181c]">
        <div class="w-[300px] h-[calc(100vh-140px)] pt-[6px]">
          <div
            class="items w-[90%] h-[180px] mx-[auto] mt-[4px] bg-[#232324] rounded-[10px] flex items-center flex-col"
            v-for="item in chartsList"
            :key="item.id"
            draggable="true"
            @dragover.prevent
            @dragstart.native="drag($event)"
            :data-type="item.value"
            :data-canreq="item.canReq"
          >
            <div
              :data-type="item.value"
              :data-canreq="item.canReq"
              class="title text-[#e9e9ea] text-[14px] mb-[4px]"
            >
              {{ item.name }}
            </div>
            <img
              :data-type="item.value"
              :data-canreq="item.canReq"
              class="w-[80%] h-[80%]"
              :src="getImageUrl(item.value + '.png')"
            />
          </div>
        </div>
      </el-scrollbar>
    </el-tab-pane>
    <el-tab-pane
      label="其它"
      name="other"
      class="bg-[#232324] pb-[10px] h-[calc(100vh-10px)]"
    >
      <el-scrollbar class="bg-[#18181c] pb-[130px]">
        <div class="w-[300px] h-[calc(100vh-60px)] pt-[6px]">
          <div
            class="items w-[90%] h-[180px] mx-[auto] mt-[4px] bg-[#232324] rounded-[10px] flex items-center flex-col"
            v-for="item in otherList"
            :key="item.id"
            draggable="true"
            @dragover.prevent
            @dragstart.native="drag($event)"
            :data-type="item.value"
            :data-canreq="item.canReq"
          >
            <div
              :data-type="item.value"
              :data-canreq="item.canReq"
              class="title text-[#e9e9ea] text-[14px] mb-[4px]"
            >
              {{ item.name }}
            </div>
            <img
              :data-type="item.value"
              :data-canreq="item.canReq"
              class="w-[80%] max-h-[80%] mb-[8px]"
              :src="getImageUrl(item.value + '.png')"
            />
          </div>
        </div>
      </el-scrollbar>
    </el-tab-pane>
  </el-tabs>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { getImageUrl } from "@renderer/utils/other";
import { chartsList, otherList } from "./data";
const activeName = ref("charts");

const drag = (e) => {
  e.dataTransfer.effectAllowed = "move";
  e.dataTransfer.setData("name", e.target.dataset.type);
  e.dataTransfer.setData("canReq", e.target.dataset.canreq);
};
</script>

<style scoped lang="scss"></style>
